package com.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.entity.User;


@Component
@Transactional//开启事务(需要配置)
public class UserDao {
	
	@Autowired
	private HibernateTemplate hibernateTemplate;
	
	public void add() {
		User user = new User();
		user.setUsername("mengma");
		user.setPassword("123");
		hibernateTemplate.save(user);
		System.out.println("userDao被执行到");
	}
}
